package com.unitedvision.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.persistence.EntityNotFoundException;

import com.unitedvision.persistence.domain.CompanyCustomerEntity;
import com.unitedvision.persistence.domain.CompanyEntity;
import com.unitedvision.persistence.domain.OperatorEntity;
import com.unitedvision.persistence.domain.TransactionEntity;
import com.unitedvision.persistence.repository.TransactionRepository;
import com.unitedvision.service.TransactionService;

public class TransactionServiceImpl implements TransactionService {

	@Resource
	private TransactionRepository transactionRepository;
	
	@Override
	public void save(TransactionEntity transaction) {
		transactionRepository.save(transaction);
	}

	@Override
	public void delete(TransactionEntity transaction) {
		transactionRepository.delete(transaction);
	}

	@Override
	public TransactionEntity get(int id) throws EntityNotFoundException {
		return transactionRepository.findOne(id);
	}

	@Override
	public List<TransactionEntity> getAll() throws EntityNotFoundException {
		return transactionRepository.findAll();
	}

	@Override
	public List<TransactionEntity> getByOperator(OperatorEntity operator) throws EntityNotFoundException {
		return transactionRepository.findByOperator(operator);
	}

	@Override
	public List<TransactionEntity> getByCompany(CompanyEntity company) throws EntityNotFoundException {
		return transactionRepository.findByCompany(company);
	}

	@Override
	public List<TransactionEntity> getByCompanyCustomer(CompanyCustomerEntity companyCustomer) throws EntityNotFoundException {
		return transactionRepository.findByCompanyCustomer(companyCustomer);
	}

	@Override
	public List<TransactionEntity> getByTransactionDateAndCompany(Date transactionDate, CompanyEntity company) throws EntityNotFoundException {
		return transactionRepository.findByTransactionDateAndCompany(transactionDate, company);
	}

	@Override
	public long count() {
		return transactionRepository.count();
	}
}
